<?php
require 'include/global.php';
require './include/validate.php';
require './include/all_left.php';
include("FCKeditor/fckeditor.php") ;

require_once 'include/advisory_db.php';
$_showDbData = 1;

if($_GET[action]=='edit'){
	$rs = $DB->fetch_one_array("SELECT * FROM " . $db_prefix . "resume WHERE `re_id`='".$_GET[id]."' AND `re_uid`= '".$_SESSION[uid]."'");
	 if(empty($rs)){
	   echo "<meta http-equiv=\"refresh\" content=\"0;URL=errorall.php?errid=rc_1012\">";
	   exit;
	 }
}

if($_GET[action]=='clear'){
     $rs = $DB->fetch_one_array("SELECT * FROM " . $db_prefix . "resume WHERE `re_id`='".$_GET[id]."' AND `re_uid`= '".$_SESSION[uid]."'");
     if(empty($rs)){
	   echo "<meta http-equiv=\"refresh\" content=\"0;URL=errorall.php?errid=rc_1012\">";
	   exit;
	 }
     $sql = "UPDATE `pa_resume` SET `re_usertype` = '',`re_uname` = '',`re_jobsearchstatus` = '',`re_fname` = '',`re_lname` = '',`re_email` = '',`re_address1` = '',`re_locity` = '',`re_lostate` = '',`re_locountry` = '',`re_lozipcode` = '',`re_phone1` = '',`re_phone2` = '',`re_rccomment` = '',`re_jobtype` = '',`re_jobindustry` = '',`re_crtjobtitle` = '',`re_jobtitle` = '',`re_currentpay` = '',`re_desiredpay` = '',`re_benefits` = '',`re_schoolattend` = '',`re_yearexp` = '',`re_edulevel` = '',`re_mgmt` = '',`re_profit` = '',`re_spoken` = '',`re_ip` = '',`re_ussecurity` = '',`re_authorize` = '',`re_detail` = '',`re_prvemployer` = '',`re_private`=0 WHERE `re_id` = '$_GET[id]'";
     $DB->query($sql);
}

$smarty->display('header.tpl');
include ("./check/checkpostresume.php");
        if($_showDbData == 1)
        {
			if($_SESSION[usertype]=="candidate"||$_SESSION[usertype]=="advisor"){
				$rs = $DB->fetch_one_array("SELECT * FROM " . $db_prefix . "resume WHERE re_usertype='".$_SESSION[usertype]."' AND re_uid ='" . $_SESSION[uid]."' ORDER BY re_regtime ASC ");
			}
			if($_SESSION[usertype]=="recruiter"&&$_GET[id]!=''){
				$rs = $DB->fetch_one_array("SELECT * FROM " . $db_prefix . "resume WHERE re_usertype='".$_SESSION[usertype]."' AND re_uid ='" . $_SESSION[uid]."' AND re_id='".$_GET[id]."'");
			}
		//print_r($rs);
			$re_id    = $rs[re_id];
			$re_fname = $rs[re_fname];
            $re_lname = $rs[re_lname];
            $re_email = $rs[re_email];
            $re_address1 = $rs[re_address1];
            $re_address2 = $rs[re_address2];
            $re_lostate = $rs[re_lostate];
            $re_locountry = $rs[re_locountry];
			$re_lozipcode = $rs[re_lozipcode];
            $re_locity = $rs[re_locity];
            $re_phone1 = $rs[re_phone1];
            $re_phone2 = $rs[re_phone2];
            $re_rccomment = $rs[re_rccomment];
            $re_nickname = $rs[re_nickname];
            $re_jobtype = $rs[re_jobtype];
            $re_jobindustry = $rs[re_jobindustry];
            $re_jobtitle = $rs[re_jobtitle];
            $re_crtjobtitle = $rs[re_crtjobtitle];
            $re_yearexp = $rs[re_yearexp];
            $re_edulevel = $rs[re_edulevel];
            $re_proflicense = $rs[re_proflicense];
            $re_mgmt = $rs[re_mgmt];
            $re_profit = $rs[re_profit];
            $re_spoken = $rs[re_spoken];
            $re_prolang = $rs[re_prolang];
            $re_ip = $rs[re_ip];
            $re_ussecurity = $rs[re_ussecurity];
            $re_authorize = $rs[re_authorize];
            $re_detail = $rs[re_detail];
            $re_comments = $rs[re_comments];
			$re_regtime  = $rs[re_regtime];
			$re_upload   = $rs[re_upload];
			$re_uploadresume   = $rs[re_uploadresume];
			$re_jobsearchstatus = $rs[re_jobsearchstatus];
			$re_describeme = $rs[re_describeme];
			$re_favoriatebook = $rs[re_favoriatebook];
			$re_highachieve = $rs[re_highachieve];
			$re_iplan = $rs[re_iplan];
			$re_iliketo = $rs[re_iliketo];
			$re_comments = $rs[re_comments];
			$re_prvemployer = $rs[re_prvemployer];
			$re_prvempstatus = $rs[re_prvempstatus];
			$re_professavilable = $rs[re_professavilable];
			$re_currentpay  = $rs[re_currentpay];
			$re_desiredpay= $rs[re_desiredpay];
			$re_benefits= $rs[re_benefits];
			$re_schoolattend= $rs[re_schoolattend];
			$re_personalweb = $rs[re_personalweb];
			$re_private     = $rs[re_private];
			$re_updtime     = $rs[re_updtime];
			$re_sponsorship = $rs[re_sponsorship];
			$ifshow_email = $rs['ifshow_email'];
			$ifshow_address1 = $rs['ifshow_address1'];
			$ifshow_address2 = $rs['ifshow_address2'];
			$ifshow_locity = $rs['ifshow_locity'];
			$ifshow_lostate = $rs['ifshow_lostate'];
			$ifshow_locountry = $rs['ifshow_locountry'];
			$ifshow_lozipcode = $rs['ifshow_lozipcode'];
			$ifshow_phone1 = $rs['ifshow_phone1'];
        }
		
        if($re_regtime==''){   
			$re_regtime = time();
		}
		if(empty($_GET[id])){
		  $editid = $re_id;
		}else{
	      $editid = $_GET[id];
		}

		ob_clean();
		ob_start();

	//back to submitapplicant
	if($re_locountry == ''){
		$re_locountry = 211;
		$re_nickname = "Recruiter Candidate";
	}


     $return = ($_POST['return'])?$_POST['return']:$_GET['return'];

		$cpforms->formheader(array ('title' => 'Candidate Record','name' => 'article','enctype' => 'multipart/form-data'));
		$cpforms->makehidden(array ('name' => 'action','value' => 'resume_doupdate'));
		$cpforms->makehidden(array ('name' => 'editid','value'=>$editid ));
		$cpforms->makehidden(array ('name' => 'return','value'=>$return));
		$cpforms->gethightext(array ('text' => "Create Date",'value' => date("m/d/Y",$re_regtime), 'view' => 1));
		if($re_updtime==0){$re_updtime = $re_regtime;}
		$cpforms->gethightext(array('text'=>"Last Updated",'value'=>date("m/d/Y",$re_updtime),'view'=>"1"));
		$cpforms->makeselect(array ('one'=>1,'text' => "Job Search Status",'name' => "re_jobsearchstatus",'option' => $jobSearchStatus,'selected' => "$re_jobsearchstatus",'view' => "$view" ,'icon'=>"'Indicate  job search status.  You may edit this later.', WIDTH, 200, SHADOW, true"));
		
		if($_SESSION['usertype'] == 'candidate'){
		$cpforms->longline(array('title'=>"Contact Information",'right'=>"Check to Show"));
		}else{
		$cpforms->longline(array('title'=>"Contact Information (Fields marked (secure) are not displayed when you set the record to public or submit it to jobs.)"));
		$dontshow = 1;
		}
		$cpforms->gethightext(array ('text' => "First Name (secure)",'name' => "re_fname",'only' => 1,'value' => "$re_fname",'view' => "$view",));
		$cpforms->gethightext(array ('text' => "Last Name (secure)",'name' => "re_lname",'only' => 1,'value' => "$re_lname",'view' => "$view"));

		if($_SESSION[usertype]=="recruiter"){
		$cpforms->gethightext(array ('text' => "Nick Name",'name' => "re_nickname",'only' => 0,'value' => "$re_nickname",'view' => "$view",'icon'=>"'Create a nick name for this candidate. When you submit this candidate profile to a job, the recipient will only see the Nick Name.', WIDTH, 200, SHADOW, true"));	
		}

		$cpforms->gethightext(array ('text' => "Contact Email (secure)",'name' => "re_email",'only' => 1,'value' => "$re_email",'view' => "$view","ifshow"=>array("name"=>"ifshow_email","value"=>"$ifshow_email","dontshow"=>$dontshow)));
		$cpforms->gethightext(array ('text' => "Street Address 1 (secure)",'name' => "re_address1",'only' => 0,'value' => "$re_address1",'view' => "$view","ifshow"=>array("name"=>"ifshow_address1","value"=>"$ifshow_address1","dontshow"=>$dontshow)));
		$cpforms->gethightext(array ('text' => "Street Address 2 (secure)",'name' => "re_address2",'value' => "$re_address2",'view' => "$view","ifshow"=>array("name"=>"ifshow_address2","value"=>"$ifshow_address2","dontshow"=>$dontshow)));
		$cpforms->gethightext(array ('text' => "City",'only' => 0,'name' => "re_locity",'value' => "$re_locity",'view' => "$view","ifshow"=>array("name"=>"ifshow_locity","value"=>"$ifshow_locity","dontshow"=>1)));
		$cpforms->makeselect(array ('one'=>1,'text' => "State",'name' => "re_lostate",'only' => 0,'option' => $state,'selected' => "$re_lostate",'view' => "$view",'viewfunction' => 'state',"ifshow"=>array("name"=>"ifshow_lostate","value"=>"$ifshow_lostate","dontshow"=>1)));
		$cpforms->makeselect(array ('one'=>1,'text' => "Country",'name' => "re_locountry",'only' => 0,'option' => $country,'selected' => "$re_locountry",'view' => "$view",'viewfunction' => 'country',"ifshow"=>array("name"=>"ifshow_locountry","value"=>"$ifshow_locountry","dontshow"=>1)));
		$cpforms->gethightext(array ('text' => "Zip Code",'name' => "re_lozipcode",'value' => "$re_lozipcode",'view' => "$view","ifshow"=>array("name"=>"ifshow_lozipcode","value"=>"$ifshow_lozipcode","dontshow"=>$dontshow)));
		$cpforms->gethightext(array ('text' => "Primary Phone (secure)",'name' => "re_phone1",'only' => 0,'value' => "$re_phone1",'view' => "$view","ifshow"=>array("name"=>"ifshow_phone1","value"=>"$ifshow_phone1","dontshow"=>$dontshow)));
		
		if($_SESSION[usertype]=="recruiter"){
		$cpforms->maketextarea(array ('text' => "Recruiter Contact",'id'=>"re_phone2",'name' => "re_phone2",'value' => "$re_phone2",'view' => "$view",'icon'=>"'Include your contact information here', WIDTH, 200, SHADOW, true"));
		$cpforms->makefck(array ('text' => "Add a note or comment about this candidate (secure)",'name' => "re_rccomment",'id'=>"re_rccomment",'only' => 0,'value' => $re_rccomment,'view' => "$view",'icon'=>"'Add notes or comments about this candidate here.', WIDTH, 200, SHADOW, true"));	
		}
		$cpforms->longline(array('title'=>"Desired Job Detail"));
		$cpforms->makeselect(array ('one'=>1,'text' => "Desired Job Type",'name' => "re_jobtype",'option' => $jobtype,'only' => 0,'selected' => "$re_jobtype",'view' => "$view"));
		$cpforms->makeselect(array ('one'=>1,'text' => "Desired Job Industry",'name' => "re_jobindustry",'option' => $jobcategory,'only' => 0,'selected' => "$re_jobindustry",'view' => "$view"));
		$cpforms->gethightext(array ('text' => "Current Job Title",'name' => "re_crtjobtitle",'only' => 0,'value' => "$re_crtjobtitle",'view' => "$view"));
		$cpforms->gethightext(array ('text' => "Desired Job Title",'name' => "re_jobtitle",'only' => 0,'value' => "$re_jobtitle",'view' => "$view"));
		$cpforms->gethightext(array ('text' => "Current Base Pay (secure)",'name' => "re_currentpay",'value' => "$re_currentpay",'view' => "$view",'icon'=>"'Indicate current annual base salary', WIDTH, 200, SHADOW, true","prev"=>"$","next"=>"(No Commas)","size"=>"10"));
		$cpforms->gethightext(array ('text' => "Desired Base Pay",'name' => "re_desiredpay",'value' => "$re_desiredpay",'view' => "$view",'icon'=>"'Indicate desired annual base salary', WIDTH, 200, SHADOW, true","prev"=>"$","next"=>"(No Commas)","size"=>"10"));
		$cpforms->maketextarea(array ('text' => "Other Compensation/Benefits",'id'=>"re_benefits",'name' => "re_benefits",'value' => stripslashes($re_benefits),'view' => "$view",'icon'=>"'Indicate other preferred compensation or benefits such as sign-on bonus or stock grants.  ', WIDTH, 200, SHADOW, true"));
		$cpforms->longline(array('title'=>"Qualifications"));
		$cpforms->maketextarea(array ('text' => "Schools Attended",'id'=>"re_schoolattend",'name' => "re_schoolattend",'value' => stripslashes($re_schoolattend),'view' => "$view"));

		$cpforms->makeselect(array ('one'=>1,'text' => "Years of Work Experience",'name' => "re_yearexp",'only' => 0,'option' => $yearexp2,'selected' => "$re_yearexp",'view' => "$view",'viewfunction' => 'yearexp'));
		$cpforms->makeselect(array ('one'=>1,'text' => "Highest Education",'name' => "re_edulevel",'only' => 0,'option' => $education,'selected' => "$re_edulevel",'view' => "$view",'viewfunction' => 'education','icon'=>"' Indicate the highest level of education achieved here.', WIDTH, 200, SHADOW, true"));
		$cpforms->gethightext(array ('text' => "Professional Licenses/Certification",'name' => "re_proflicense",'value' => "$re_proflicense",'view' => "$view",'icon'=>"'List all professional licenses or certifications obtained here.', WIDTH, 200, SHADOW, true"));
		$cpforms->makeselect(array ('one'=>1,'text' => "Years of People Mgmt Experience",'name' => "re_mgmt",'only' => 0,'option' => $yearexp2,'selected' => "$re_mgmt",'view' => "$view",'viewfunction' => 'yearexp'));
		$cpforms->makeselect(array ('one'=>1,'text' => "Years of Profit & Loss Responsibility",'name' => "re_profit",'only' => 0,'option' => $yearexp2,'selected' => "$re_profit",'view' => "$view",'viewfunction' => 'yearexp'));
		$cpforms->gethightext(array ('text' => "Spoken Language(s)",'name' => "re_spoken",'only' => 0,'value' => "$re_spoken",'view' => "$view"));
		$cpforms->gethightext(array ('text' => "Programming Language Knowledge",'name' => "re_prolang",'value' => "$re_prolang",'view' => "$view"));
		$cpforms->gethighradio(array ('text' => "High-Tech Patent/IP owner or Co-owner?",'name' => "re_ip",'only' => 0,'selected' => "$re_ip",'view' => "$view"));
		$cpforms->gethighradio(array ('text' => "Government Security Clearance?",'name' => "re_ussecurity",'only' => 0,'selected' => "$re_ussecurity",'view' => "$view"));
		$cpforms->maketextarea(array ('text' => "Authorized To Work In The Following Country",'id'=>"re_authorize",'name' => "re_authorize",'only' => 0,'value' => "$re_authorize",'view' => "$view" ,'icon'=>"' Indicate in which country the candidate is authorized to work.', WIDTH, 200, SHADOW, true"));
		$cpforms->makefck(array ('text' => "Add Resume Details or Profile Description Here (Do not include names and contact information.) ",'name' => "re_detail",'id'=>"re_detail",'only' => 0,'value' => (($re_detail==NULL || $re_detail=="")?"":stripslashes($re_detail)),'view' => "$view",'icon'=>"'Include resume details or create a profile.  Do not include the candidate name or contact information unless you wish to share it.', WIDTH, 200, SHADOW, true"));
       	$cpforms->makefile(array ('text' => "Photo (Only accept image size less than 50KB.)",'name' => "uploadfile",'value'=>"$re_upload",'url'  => "uploadfiles/resumes/",'view' => "$view"));
       	$cpforms->makefile(array ('text' => "Resume File (Only accept doc/docx/txt/pdf files size less than 5MB.)",'name' => "uploadresume",'value'=>"$re_uploadresume",'url'  => "uploadfiles/resumes/",'view' => "$view",'filetype'=>'View Resume'));
		
		if($_SESSION[usertype]=="candidate"||$_SESSION[usertype]=="advisor"){
			$cpforms->longline(array('title'=>"More About Me…"));
			$cpforms->maketextarea(array ('text' => "My family/friends would describe me as…",'name' => "re_describeme",'id'=>"re_describeme",'value' => "$re_describeme",'view' => "$view",'icon'=>"'Please describe in 250 characters or less.  You may edit this later.', WIDTH, 200, SHADOW, true"));
			$cpforms->maketextarea(array ('text' => "My favoriate book is…because…",'name' => "re_favoriatebook",'id'=>"re_favoriatebook",'value' => "$re_favoriatebook",'view' => "$view",'icon'=>"'Please describe in 250 characters or less.  You may edit this later.', WIDTH, 200, SHADOW, true"));
			$cpforms->maketextarea(array ('text' => "My highest achievement is…",'name' => "re_highachieve",'id'=>"re_highachieve",'value' => "$re_highachieve",'view' => "$view",'icon'=>"'Please describe in 250 characters or less.  You may edit this later.', WIDTH, 200, SHADOW, true"));
			$cpforms->maketextarea(array ('text' => "In 3 to 5 years, I plan to…",'name' => "re_iplan",'id'=>"re_iplan",'value' => "$re_iplan",'view' => "$view",'icon'=>"'Please describe in 250 characters or less.  You may edit this later.', WIDTH, 200, SHADOW, true"));
			$cpforms->maketextarea(array ('text' => "When I'm not working I like to…",'name' => "re_iliketo",'id'=>"re_iliketo",'value' => "$re_iliketo",'view' => "$view",'icon'=>"'Please describe in 250 characters or less.  You may edit this later.', WIDTH, 200, SHADOW, true"));
			$cpforms->maketextarea(array ('text' => "My Personal Website or Blog Link ",'name' => "re_personalweb",'id'=>"re_personalweb",'value' => "$re_personalweb",'view' => "$view"));
			$cpforms->maketextarea(array ('text' => "Comments",'name' => "re_comments",'id'=>"re_comments",'only' => 0,'value' => stripslashes($re_comments),'view' => "$view",'icon'=>"'You may include additional comments here for view by recruiters.', WIDTH, 200, SHADOW, true"));
		}
		if($_SESSION[usertype]=="recruiter"){
		    $cpforms->longline(array('title'=>"Work Status, Employment and Professional References"));
			$cpforms->maketextarea(array ('text' => "List Previous Employers",'id'=>"re_prvemployer",'name' => "re_prvemployer",'only' => 0,'value' => "$re_prvemployer",'view' => "$view",'icon'=>"'Please list 3 previous employers.', WIDTH, 200, SHADOW, true"));
		    $cpforms->gethighradio(array ('text' => "Previous Employment Status Checked?",'name' => "re_prvempstatus",'only' => 0,'selected' => "$re_prvempstatus",'view' => "$view",'icon'=>"'Select \'Yes\' if previous employment have been verified.', WIDTH, 200, SHADOW, true"));
			 $cpforms->gethighradio(array ('text' => "Professional References Available?",'name' => "re_professavilable",'only' => 0,'selected' => "$re_professavilable",'view' => "$view",'icon'=>"'Select \'Yes\' if references are available for contact.', WIDTH, 200, SHADOW, true"));
			 // $cpforms->gethighradio(array ('text' => "Will the applicant require work sponsorship for this job?",'name' => "re_sponsorship",'only' => 0,'selected' => "$re_sponsorship",'view' => "$view"));
		    $cpforms->longline(array('title'=>"Resume Privacy Setting"));
		}
			if($re_private == ''){  $re_private = 1; }

			$cpforms->gethighradio(array ('text' => "Current Status",'name' => "re_private",'options'=>$pri_pub,'only' => 0,'selected' => "$re_private",'view' => "$view",'icon'=>"'Your record is private and only visible to you.  Change to \'Public\' to make your record visible and searchable by recruiters.', WIDTH, 200, SHADOW, true"));

		//	$cpforms->makePhpCaptcha(array('text'=>"Safe Code",'name'=>"imagecode",'value'=>"$_POST[imagecode]",'only'=>1));
		if($_GET[action]=='edit'||!empty($rs)){
           if(($_SESSION[usertype]=='candidate'&&!empty($rs))||($_SESSION[usertype]=='advisor'&&!empty($rs))){
			   $cpforms->formfooter(array (
				'confirm' => 3,
				'delete'  => 1,
				're_id'   => $rs[re_id]
					));
		   }else{
		      $cpforms->formfooter(array (
				'confirm' => 3
		      ));
		   }
		}else{
			$cpforms->formfooter(array (
				'confirm' => 1
			));
		}

		$reg_data = ob_get_contents();
		ob_end_clean();

		if ($err != '')
		{
			$smarty->assign("err", $err);
		}
		$smarty->assign("reg", $reg_data);
        
		if($_SESSION[usertype]=='candidate'||$_SESSION[usertype]=='advisor'){//if candidate
					$title   = "My Resume";
					$content = "Here you can post and manage your resume. (<font color=red>*</font> = Required Field) ";
		}else{
		            $title   = "Add/Edit Candidate";
					$content = "Add your candidate information here. (<font color=red>*</font> = Required Field) ";
		}

		if($_SESSION[uid] == $rs[re_uid] && $_SESSION[usertype] == "recruiter" && $_SESSION['status'] == "Premium"){
			$smarty->assign("aliasbutton",'<span style="float:right;padding: 0 10px 0 0 "><input type="button" value="Create Alias" onclick="location.href=\'postresumealias.php?id='.$rs[re_id].'\'" class="button-secondary"> <a href="###" onmouseover="Tip(\'You may create up to 99  alias copies of this candidate record.\', WIDTH, 200, SHADOW, true)"><img src="images/icn_question.jpg" border="0" align="absmiddle" /></a></span>');
		}

		$smarty->assign('title',$title);
		$smarty->assign('content',$content);
		$smarty->display('allleft.tpl');
		$smarty->display('reg.tpl');


$smarty->display('allright.tpl');
$smarty->display('footer.tpl');
?>
